package cn.tedu.test;

import cn.tedu.service.UserInfoMapper;
import cn.tedu.pojo.UserInfo;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class UserInfoGet {
    @Test
    public void get() throws IOException {
        InputStream in = Resources.getResourceAsStream("mybatis-config.xml");
        SqlSessionFactory session = new SqlSessionFactoryBuilder().build(in);
        SqlSession sqlSession = session.openSession(true);
        UserInfoMapper mapper = sqlSession.getMapper(UserInfoMapper.class);
        List<UserInfo> all = mapper.getAll();
        System.out.println(all);
        for (UserInfo userInfo : all) {
            System.out.println(userInfo);
        }
    }
}
